package com.example.patentback.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Table(name = "sys_menu")
public class SysMenu {
    @Id
    private Long id;

    /**
     * 父菜单ID，一级菜单为0
     */
    @Column(name = "parent_id")
    @NotNull(message = "上级菜单不能为空")
    private Long parentId;

    @NotBlank(message = "菜单名称不能为空")
    private String name;

    /**
     * 菜单URL
     */
    private String path;

    /**
     * 授权(多个用逗号分隔，如：user:list,user:create)
     */
    @NotBlank(message = "菜单授权码不能为空")
    private String perms;

    private String component;

    /**
     * 类型     0：目录   1：菜单   2：按钮
     */
    @NotNull(message = "菜单类型不能为空")
    private Integer type;

    /**
     * 菜单图标
     */
    private String icon;

    /**
     * 排序
     */
    @Column(name = "orderNum")
    private Integer ordernum;

    @Transient
    private List<SysMenu> children = new ArrayList<>();

    private Date created;

    private Date updated;

    private Integer statu;

    /**
     * @return id
     */
    public Long getId() {
        return id;
    }

    /**
     * @param id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * 获取父菜单ID，一级菜单为0
     *
     * @return parent_id - 父菜单ID，一级菜单为0
     */
    public Long getParentId() {
        return parentId;
    }

    /**
     * 设置父菜单ID，一级菜单为0
     *
     * @param parentId 父菜单ID，一级菜单为0
     */
    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    /**
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取菜单URL
     *
     * @return path - 菜单URL
     */
    public String getPath() {
        return path;
    }

    /**
     * 设置菜单URL
     *
     * @param path 菜单URL
     */
    public void setPath(String path) {
        this.path = path;
    }

    /**
     * 获取授权(多个用逗号分隔，如：user:list,user:create)
     *
     * @return perms - 授权(多个用逗号分隔，如：user:list,user:create)
     */
    public String getPerms() {
        return perms;
    }

    /**
     * 设置授权(多个用逗号分隔，如：user:list,user:create)
     *
     * @param perms 授权(多个用逗号分隔，如：user:list,user:create)
     */
    public void setPerms(String perms) {
        this.perms = perms;
    }

    /**
     * @return component
     */
    public String getComponent() {
        return component;
    }

    /**
     * @param component
     */
    public void setComponent(String component) {
        this.component = component;
    }

    /**
     * 获取类型     0：目录   1：菜单   2：按钮
     *
     * @return type - 类型     0：目录   1：菜单   2：按钮
     */
    public Integer getType() {
        return type;
    }

    /**
     * 设置类型     0：目录   1：菜单   2：按钮
     *
     * @param type 类型     0：目录   1：菜单   2：按钮
     */
    public void setType(Integer type) {
        this.type = type;
    }

    /**
     * 获取菜单图标
     *
     * @return icon - 菜单图标
     */
    public String getIcon() {
        return icon;
    }

    /**
     * 设置菜单图标
     *
     * @param icon 菜单图标
     */
    public void setIcon(String icon) {
        this.icon = icon;
    }

    /**
     * 获取排序
     *
     * @return orderNum - 排序
     */
    public Integer getOrdernum() {
        return ordernum;
    }

    /**
     * 设置排序
     *
     * @param ordernum 排序
     */
    public void setOrdernum(Integer ordernum) {
        this.ordernum = ordernum;
    }

    /**
     * @return created
     */
    public Date getCreated() {
        return created;
    }

    /**
     * @param created
     */
    public void setCreated(Date created) {
        this.created = created;
    }

    /**
     * @return updated
     */
    public Date getUpdated() {
        return updated;
    }

    /**
     * @param updated
     */
    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    /**
     * @return statu
     */
    public Integer getStatu() {
        return statu;
    }

    /**
     * @param statu
     */
    public void setStatu(Integer statu) {
        this.statu = statu;
    }

    public List<SysMenu> getChildren() {
        return children;
    }

    public void setChildren(List<SysMenu> children) {
        this.children = children;
    }

    @Override
    public String toString() {
        return "SysMenu{" +
                "id=" + id +
                ", parentId=" + parentId +
                ", name='" + name + '\'' +
                ", path='" + path + '\'' +
                ", perms='" + perms + '\'' +
                ", component='" + component + '\'' +
                ", type=" + type +
                ", icon='" + icon + '\'' +
                ", ordernum=" + ordernum +
                ", created=" + created +
                ", updated=" + updated +
                ", statu=" + statu +
                '}';
    }
}